//
//  VisitRecordCell.m
//  WanCaiC8
//
//  Created by tangang on 2018/5/1.
//  Copyright © 2018年 tangang. All rights reserved.
//

#import "VisitRecordCell.h"
#import "PlanModel.h"
@implementation VisitRecordCell{
    UIImageView *headImage;
    QXLable     *labName;
    QXLable     *labTime;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        headImage=[[UIImageView alloc]init];
        headImage.layer.masksToBounds=YES;
        headImage.layer.cornerRadius=20;
        [self.contentView addSubview:headImage];
        [headImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.equalTo(self.contentView).with.offset(10);
            make.bottom.equalTo(self.contentView).with.offset(-10);
            make.size.mas_equalTo(CGSizeMake(40, 40));
        }];
        
        labName=[[QXLable alloc]initTitle];
        [self.contentView addSubview:labName];
        [labName mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(headImage.mas_right).with.offset(10);
            make.top.equalTo(headImage);
        }];
        
        labTime=[[QXLable alloc]initWithFount:13];
        [self.contentView addSubview:labTime];
        [labTime mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(labName);
            make.bottom.equalTo(headImage);
        }];
        
        QXLable *labPrompt=[[QXLable alloc]init];
        labPrompt.text=@"访问了他的主页";
        [self.contentView addSubview:labPrompt];
        [labPrompt mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.contentView).with.offset(-10);
            make.centerY.equalTo(self.contentView);
        }];
        
        UIView *line=[[UIView alloc]init];
        line.backgroundColor=DEFAULTBGCOLOR;
        [self.contentView addSubview:line];
        [line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(headImage);
            make.bottom.right.equalTo(self.contentView);
            make.height.mas_equalTo(@.7);
        }];
    }
    return self;
}

- (void)setModel:(VisitRecordModel *)model{
    if ([model isKindOfClass:[PlanModel class]]) {
        PlanModel *pModel=(PlanModel *)model;
        [headImage sd_setImageWithURL:[NSURL URLWithString:pModel.Logo]];
        labName.text=pModel.LTypeName;
        labTime.text=pModel.SubTime;
    }else{
        [headImage sd_setImageWithURL:[NSURL URLWithString:model.Avater] placeholderImage:[UIImage imageNamed:@"avatar"]];
        labName.text=model.NickName;
        labTime.text=model.AccessTime;
    }
    
}

@end
